#!/usr/bin/python
from TackApp import TackApp

##################################################################################
def GetCLIOptions(lParams):
    """
    Convert options gathered from command line in to a dictionary form
    
    param - lParams : List of command line parameters
    
    return - dParams : Dictionary of parameters using parameter name as key
    """
    dParams = {}
    while lParams:
        if lParams[0][0] == '-':
            try:
                dParams[lParams[0][1:]] = lParams[1]
            except:
                dParams[lParams[0][1:]] = 1
            lParams = lParams[2:]
        else:
            lParams = lParams[1:]
    return dParams
##################################################################################

##################################################################################
# Main - Program entry point
##################################################################################
if __name__ == '__main__':
    
    from sys import argv
    dArgs = GetCLIOptions(argv)
    rToddPad = TackApp("Tack Game Editor", ".tackgameeditor", "/home/toddy/tgecore" , bLog=1, bUseRightClickMenu=1)
    
    bAsCore = 0
    if(dArgs.has_key('c')): bAsCore = 1
    
    if(dArgs.has_key('i')):
        # Install an extension if one ihas been passed
        rToddPad.InstallExtension(dArgs['i'], bAsCore)
    elif(dArgs.has_key('u')):
        # Install an extension if one ihas been passed
        rToddPad.UninstallExtension(dArgs['u'], bAsCore)
    elif(dArgs.has_key('f')):
        # Open a file if one has been passed
        rToddPad.Show(dArgs['f'])
    else:
        # Otherwise open with a new file
        rToddPad.Show()
